
from qcloud_cos import CosConfig
from qcloud_cos import CosS3Client
import sys
import logging

logging.basicConfig(level=logging.INFO, stream=sys.stdout)

secret_id = 'AKIDt78QbXkxjHadOf8FVigXx7uLWPAY6qbS'      # 替换为用户的 secretId
secret_key = 'kEQKuDrFF1ZrrzmKbnEbmg28xVpd8PP7'      # 替换为用户的 secretKey

region = 'ap-beijing'     # 替换为用户的 Region

config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, )
# 2. 获取客户端对象
client = CosS3Client(config)


response = client.upload_file(
    Bucket='xiechen-1302729577', # -1302729577  这是我们主账户的APPID
    LocalFilePath='timg.jpeg', # 本地图片路径
    Key='meinv.jpeg', # 上传到存储桶之后的文件名称

)
print(response['ETag'])


